home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / WindowColorMap.h < prev    next >
C/C++ Source or Header  |  1992-08-26  |  2KB  |  94 lines

  1. #ifndef WindowColorMap_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define WindowColorMap_First
  7.  
  8. #include "Object.h"
  9. #include "Ink.h"
  10.  
  11. class Port;
  12. class WindowPort;
  13.  
  14. #if 0
  15. #   define MAXREDS      5
  16. #   define MAXGREENS    9
  17. #   define MAXBLUES     5
  18. #else
  19. #   define MAXREDS      6
  20. #   define MAXGREENS    6
  21. #   define MAXBLUES     6
  22. #endif
  23. #   define MAXGREYS     15
  24.  
  25. #define Pixel(r,g,b)                                                    \
  26.             ((((r)*(MAXREDS-1))/255) * MAXGREENS * MAXBLUES    \
  27.             + (((g)*(MAXGREENS-1))/255) * MAXBLUES              \
  28.             + (((b)*(MAXBLUES-1))/255)                          \
  29.             )
  30.  
  31. //---- WindowColorMap ----------------------------------------------------------
  32.  
  33. class WindowColorMap : public Object {
  34.     static int cnt;
  35.  
  36.     int refcnt;
  37. public:
  38.     int changed;
  39. protected:
  40.     bool rw, grey;
  41.     int id;
  42.  
  43.     virtual u_long DevAllocateAndSetCell(long id, RGB *rgb, WindowPort*);
  44.     virtual void DevInstall(Port *port);
  45.     virtual u_long DevRGB2Index(RGB *rgb, RGB *result);
  46.     virtual u_long DevRGB2Index2(RGB *rgb);
  47.     virtual void DevIndex2RGB(u_long ix, RGB *result);
  48.     virtual WindowColorMap *DevMakeCopy(WindowColorMap *from);
  49.  
  50.     ~WindowColorMap();
  51. public:
  52.     MetaDef(WindowColorMap);
  53.     WindowColorMap();
  54.     WindowColorMap(WindowColorMap *from);
  55.     void Ref()
  56.     { refcnt++; }
  57.     void Unref();
  58.     
  59.     int GetId()
  60.     { return id; }
  61.     u_long RGB2Index(RGB *rgb, RGB *result= 0)
  62.     { return DevRGB2Index(rgb, result); }
  63.     void Index2RGB(u_long ix, RGB *result)
  64.     { DevIndex2RGB(ix, result); }
  65.     u_long AllocateAndSetCell(long id, RGB *rgb, WindowPort*);
  66.     void Install(Port *port)
  67.     { if (changed > 0) DevInstall(port); }
  68.     bool IsGrey()
  69.     { return grey; }
  70.     WindowColorMap *MakeCopy(WindowColorMap *from)
  71.     { return DevMakeCopy(from); }
  72. };
  73.  
  74. //---- WindowIndexMapper -------------------------------------------------------
  75.  
  76. class WindowIndexMapper : public WindowColorMap {
  77. protected:
  78.     int length;
  79.     RGB *realmap;
  80.     u_long *graymap, *rgbmap;
  81.  
  82.     u_long DevRGB2Index(RGB *rgb, RGB *result);
  83.     void DevIndex2RGB(u_long ix, RGB *result);
  84.  
  85.     ~WindowIndexMapper();
  86. public:
  87.     MetaDef(WindowIndexMapper);
  88.     WindowIndexMapper();
  89.     WindowIndexMapper(WindowIndexMapper *from);
  90. };
  91.  
  92. #endif
  93.  
  94.